package com.yuyou.fn.activity.service.impl;

import com.github.wens.mybatisplus.examples.Example;
import com.yuyou.fn.common.util.Utils;
import org.springframework.stereotype.Service;

import com.yuyou.fn.activity.mapper.ActivityCampusSessionMapper;
import com.yuyou.fn.activity.entity.ActivityCampusSession;
import com.yuyou.fn.activity.service.IActivityCampusSessionService;
import com.github.wens.framework.service.impl.SuperServiceImpl;

import java.util.Collections;
import java.util.List;

/**
 *
 * ActivityCampusSession 表数据服务层接口实现类
 *
 */
@Service
public class ActivityCampusSessionServiceImpl extends SuperServiceImpl<ActivityCampusSessionMapper, ActivityCampusSession,Long> implements IActivityCampusSessionService {

    @Override
    public void deleteSessionByActivityId(long activityId) {
        Example<ActivityCampusSession> example=ActivityCampusSession.createExample();
        example.createCriteria().andEqualTo("activityId",activityId);
        this.deleteByExample(example);
    }

    @Override
    public List<ActivityCampusSession> findSessionByActivityCampusId(long activityCampusId) {
        Example<ActivityCampusSession> example=ActivityCampusSession.createExample();
        example.createCriteria().andEqualTo("activityCampusId",activityCampusId);
        return this.findListByExample(example);
    }

    @Override
    public List<ActivityCampusSession> findSessionByActivityIdCampusIdShowStatus(long activityId, long campusId, int showStatus) {
        Example<ActivityCampusSession> example=ActivityCampusSession.createExample();
        example.createCriteria().andEqualTo("activityId",activityId).andEqualTo("campusId",campusId).andEqualTo("showStatus",showStatus);
        return this.findListByExample(example);
    }

    @Override
    public List<ActivityCampusSession> findSessionByActivityCampusIds(List<Long> activityCampusIds) {
        if (Utils.isEmpty(activityCampusIds)){
            return Collections.EMPTY_LIST;
        }
        Example<ActivityCampusSession> example=ActivityCampusSession.createExample();
        example.createCriteria().andIn("activityCampusId",activityCampusIds);
        return this.findListByExample(example);
    }

    @Override
    public List<ActivityCampusSession> findSessionByActivityCampusIdsShowStatus(List<Long> activityCampusIds, int showStatus) {
        if (Utils.isEmpty(activityCampusIds)){
            return Collections.EMPTY_LIST;
        }
        Example<ActivityCampusSession> example=ActivityCampusSession.createExample();
        example.createCriteria().andIn("activityCampusId",activityCampusIds).andEqualTo("showStatus",showStatus);
        return this.findListByExample(example);
    }
}